import React, { Component } from 'react'

export default class App extends Component {
  myInput = React.createRef()
  render() {
    return (
      <div>
        <input ref={this.myInput}></input>
        <button onClick={() => {this.handleClick()}}>按钮</button>
      </div>
    )
  }
  handleClick() {
    console.log(this.myInput.current.value);// 获取input的值
  }
}

